package org.fujay.langchain4jserver.domain.knowledge.vo;

import lombok.Getter;

/**
 * 文件索引状态枚举
 */
@Getter
public enum IndexStatus {
    PENDING(0, "待处理"),
    PARSING(1, "解析中"),
    VECTORIZING(2, "向量化中"),
    STORING(3, "入库中"),
    COMPLETED(4, "完成"),
    FAILED(5, "失败");

    private final int code;
    private final String description;

    IndexStatus(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public static IndexStatus fromCode(int code) {
        for (IndexStatus status : IndexStatus.values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown IndexStatus code: " + code);
    }
}
